<!DOCTYPE html>
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>密钥管理</title>
<link rel="stylesheet" type="text/css" href="/resource/css/css.css" />
<script type="text/javascript" src="/resource/js/jquery.min.js"></script>
<script type="text/javascript" src="/resource/js/public.js"></script>
<script type="text/javascript" src="/resource/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/resource/js/contr.js"></script>
<style type="text/css">
 		.alert_01{
                text-align: center;
                background: #ffffff;
                border: 1px #ccc solid;
                border-radius: 10px;
                -webkit-border-radius: 10px;
                -moz-border-radius: 10px;
                box-shadow: 1px 1px 3px 2px #ccc;
                padding: 1% 2%;

                width: 320px;
                height: 200px;
                z-index: 1;
                position: absolute;
                left: 37%;
                top: 150px;
            }

            .alert_01 h3{font-size: 16px; line-height:28px; font-weight: bold; margin-top: 10px; text-align: center; color: black}

            .alert_01 span { position: absolute; top:10px; right:20px; z-index: 2;}
            .alert_01 btn{ float:left; cursor: pointer;font-weight: bold;background:#69B946; border-radius: 8px; color: #fff; line-height: 46px; width: 80%; margin: 10%;}
            .alert_01 btn:hover{  color: #fff; background:#69B946;filter:alpha(opacity=80);
                                  -moz-opacity:0.8;
                                  opacity:0.8;}
</style>
</head>
<body>
	<div id="pageAll">
		<div class="pageTop">
			<div class="page">
				<img src="/resource/img/coin02.png" /><span><a href="#">首页</a>&nbsp;-&nbsp;<a
					href="#">系统管理</a>&nbsp;-</span>&nbsp;密钥管理
			</div>
		</div>
		<div class="page ">
			<!-- 修改密码页面样式 -->
			<div class="bacen">
				<!-- <div class="bbD">&nbsp;&nbsp;&nbsp;&nbsp;管理员UID：&nbsp;&nbsp;&nbsp;&nbsp;123</div> -->
				<div class="bbD" style="margin-left: 100px"></div>
				<div class="bbD">
					<div style="text-align: center;margin: 0 120px 10px 0">您的密钥是:</div>
					<input type="password" style="width: 300px;" class="input3" onblur="checkkey()" id="key" value="<?php echo $key; ?>"/> 
				</div>		
				<div class="bbD">
					<p>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" onclick="showpass()">查看密钥</a> <a href="javascript:void" style="margin-left: 50px" onclick="showdown();">密钥下载</a><a href="javascript:void(0)" style="margin-left: 50px" onclick="show()">重新生成密钥</a></p>
				</div>
			</div>
			<!-- 修改密码页面样式end -->
		</div>
		 <div class="alert_01" id="showSuccess" style="display: none;">
            <h3 id="alerth3">请输入密码:</h3>

            <div class="bbD">
            	<input type="password" style="width: 300px;" class="input3" onblur="checkpwd2()" id="checkpwd" value=""/> 
            </div>
            
            <btn id="btn2" >确定</btn>
            <span style=" cursor:pointer;" id="hideSuccess" onclick="hide()">
            	<img src="/resource/img/close_mf.png" width="25" height="25" alt=""/>
            </span>
        </div>
         <div class="alert_01" id="checkpass" style="display: none;">
            <h3 id="alerth3">请输入密码:</h3>

            <div class="bbD">
            	<input type="password" style="width: 300px;" class="input3" id="checkpwd2" value=""/> 
            </div>
            
            <btn id="btn3" >确定</btn>
            <span style=" cursor:pointer;" id="hidepass" onclick="hidepass()">
            	<img src="/resource/img/close_mf.png" width="25" height="25" alt=""/>
            </span>
        </div>
          <div class="alert_01" id="downLoadcheck" style="display: none;">
            <h3 id="alerth3">请输入密码:</h3>

            <div class="bbD">
            	<input type="password" style="width: 300px;" class="input3" id="checkpwd3" value=""/> 
            </div>
            
            <btn id="btn4" >确定</btn>
            <span style=" cursor:pointer;" id="hidedown" onclick="hidedown()">
            	<img src="/resource/img/close_mf.png" width="25" height="25" alt=""/>
            </span>
        </div>
	</div>
</body>
<script type="text/javascript">

$(document).ready(function(){
	if (window.top==window.self){  
	   window.top.location="?c=admin&m=index"; 
	}
});
	function show(){
		$('#showSuccess').show();
	}
	function hide() {
		$('#showSuccess').hide();
	}
	function showpass(){
		$('#checkpass').show();
	}
	function hidepass(){
		$('#checkpass').hide();
	}
	function hidedown(){
		$('#downLoadcheck').hide();
	}
	function showdown(){
		$('#downLoadcheck').show();
	}
	$('#btn2').click(function(){
		firm();
						
	});
	/**
	*查看密钥
	*/
	$('#btn3').click(function(){
		var password = $('#checkpwd2').val();
		if(password==''){
			alert('密码不能为空');
			return false;
		} 
		 	$.ajax({
			"url":"?c=user&m=cheakPass",
			"dataType":"json",
			"data":{"password":password},
			"type":"post",
			success:function(re){
			if(re.code=='0'){	
				 showpass();
				 hidepass();
				 lookkey();
				
			}else{
				alert('密码不正确!');
			}
		}
		});
	});
	/**
	*下载密钥
	*/
	$('#btn4').click(function(){
		var password = $('#checkpwd3').val();
		if(password==''){
			alert('密码不能为空');
			return false;
		} 
		 	$.ajax({
			"url":"?c=user&m=cheakPass",
			"dataType":"json",
			"data":{"password":password},
			"type":"post",
			success:function(re){
			if(re.code=='0'){	
				 hidedown();
				//window.open('?c=user&m=downLoadkey');
				window.location.href='?c=user&m=downLoadkey';
				
			}else{
				alert('密码不正确!');
			}
		}
		});
	});


	function lookkey(){
		 $("#key").attr("type","text");
	}

	function firm() { 
    //利用对话框返回的值 （true 或者 false） 
    if (confirm("你确要修改密钥吗?")) { 
    	var password = $('#checkpwd').val();
      if(password==''){
			alert('密码不能为空');
			return false;
		}
		$.ajax({
		"url":"?c=user&m=changekey",
		"dataType":"json",
		"data":{"password":password},
		"type":"post",
		success:function(re){
			if(re.code=='0'){	
				$('#key').val(re.key);
				$('#showSuccess').hide();
			}else{
				alert('密码不正确!');
			}
		}
		});
    } else { 
      return false;
    } 
  
 	 } 
</script>
</html>